#include "StdAfx.h"
#include "CdiGUID.h"

CdiGUID::CdiGUID() 
  : m_made( true )
{
  MakeUnique();
}


CdiGUID::CdiGUID( bool makeUnique )
{
  m_made = false;
  if( makeUnique ) 
    this->MakeUnique();
}

CdiGUID::~CdiGUID(void)
{
  m_made = false;
}

void CdiGUID::MakeUnique() 
{
  if( m_made ) 
    return; 
  
  GUID guid;
  HRESULT hr = CoCreateGuid(&guid);
  
  if( FAILED( hr )  ) 
  {
    m_made = false;
    return;
  }

  BYTE* str;
  UuidToStringA( &guid, &str );

  m_strGUID = string( (char*)str );
}